#include "titlewgt.h"
#include<QHBoxLayout>

TitleWgt::TitleWgt(QWidget *parent)
    : QWidget(parent)

{
    setFixedSize(900,30);
    setWindowFlag(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_StyledBackground);

    minBtn = new QPushButton(this);
    maxBtn = new QPushButton(this);
    closeBtn = new QPushButton(this);

    minBtn->setFixedSize(30,30);
    maxBtn->setFixedSize(30,30);
    closeBtn->setFixedSize(30,30);

    connect(minBtn,&QPushButton::clicked,this,[this](){
        this->parentWidget()->showMinimized();
    });

    connect(maxBtn,&QPushButton::clicked,this,[this](){
        this->parentWidget()->showMaximized();
    });

    connect(closeBtn,&QPushButton::clicked,this,[this](){
        this->parentWidget()->close();
    });

    QHBoxLayout* hlayout = new QHBoxLayout(this);
    hlayout->addStretch();
    hlayout->addWidget(minBtn);
    hlayout->addWidget(maxBtn);
    hlayout->addWidget(closeBtn);
    hlayout->setContentsMargins(0,0,0,0);
    setLayout(hlayout);
}


